Skip to content

fix: Validate arrow_cast time units#22206

Open
Dandandan wants to merge 1 commit into
apache:mainfrom
Dandandan:fix-22194-arrow-cast-time-units
Open

fix: Validate arrow_cast time units#22206
Dandandan wants to merge 1 commit into
apache:mainfrom
Dandandan:fix-22194-arrow-cast-time-units

Conversation

@Dandandan
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

arrow_cast and arrow_try_cast accepted Arrow time type strings that combine Time32 / Time64 with unsupported units. Those invalid types could reach later planning or execution paths and panic in Arrow array code.

What changes are included in this PR?

  • Validate parsed arrow_cast / arrow_try_cast target types before returning fields or simplifying casts.
  • Reject Time32(Microsecond), Time32(Nanosecond), Time64(Second), and Time64(Millisecond).
  • Add sqllogictest coverage for the invalid combinations from the issue.

Are these changes tested?

  • cargo test -p datafusion-sqllogictest --test sqllogictests -- arrow_typeof
  • cargo clippy -p datafusion-functions --all-targets --all-features -- -D warnings
  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings

Are there any user-facing changes?

Invalid Arrow time type combinations now return a planning error instead of being accepted by arrow_cast / arrow_try_cast.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels May 15, 2026
@Dandandan Dandandan changed the title Validate arrow_cast time units fix: Validate arrow_cast time units May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arrow_cast accepts invalid Time32(Microsecond)/Time32(Nanosecond)/Time64(Second)/Time64(Millisecond), panics on use

1 participant